//% color="#FF8C00" iconWidth=50 iconHeight=40
namespace esp_DS1307{
    //% block="esp_DS1307 init " blockType="command" 
    
    export function esp_DS1307A(parameter: any, block: any) {

      

       
        Generator.addInclude("esp_DS1307A", "#include <Esp_DS1307.h>");

        Generator.addObject(`esp_DS1307A`,  "Esp_DS1307",`ds1307;`);
        
        Generator.addSetup("esp_DS1307A","ds1307.begin();");
        

    }
    //% block="esp_DS1307 [A]YEAR[B]month[C]day [D]h[E]m[F]s" blockType="command"  
    //% A.shadow="number"  A.defl="2020" 
    //% B.shadow="number"  B.defl="1"
    //% C.shadow="number"  C.defl="1" 
    //% D.shadow="number"  D.defl="0"
    //% E.shadow="number"  E.defl="0" 
    //% F.shadow="number"  F.defl="0"
    export function esp_DS1307B(parameter: any, block: any) {
        let a=parameter.A.code;
        let b=parameter.B.code;
        let c=parameter.C.code;
        let d=parameter.D.code;
        let e=parameter.E.code;
        let f=parameter.F.code;

        Generator.addInclude("esp_DS1307A", "#include <Esp_DS1307.h>");

        Generator.addObject(`esp_DS1307A`,  "Esp_DS1307",`ds1307;`);
        
        
        
        Generator.addSetup("esp_DS1307B",`ds1307.setTime(constrain(${a}, 2000, 2099), constrain(${b}, 1, 12), constrain(${c}, 1, 31), constrain(${d}, 0, 23), constrain(${e}, 0, 59), constrain(${f}, 0, 59));`);
        


    }

       //% block="esp_DS1307 [G]" blockType="reporter"  
        //% G.shadow="dropdown"  G.options="G"
    
    export function esp_DS1307C(parameter: any, block: any) {
        let g=parameter.G.code;
        
        Generator.addInclude("esp_DS1307A", "#include <Esp_DS1307.h>");

        Generator.addObject(`esp_DS1307A`,  "Esp_DS1307",`ds1307;`);

        Generator.addSetup("esp_DS1307A","ds1307.begin();");
        Generator.addSetup("esp_DS1307A1","Serial.begin(9600);",true);

        Generator.addCode([`ds1307.getTime(ds1307.${g})`,Generator.ORDER_UNARY_POSTFIX]);

    }
    
    
   
  
    
}
